/******************************************************************************* 
 * Copyright (C) 2012-2015 Microfountain Technology, Inc. All Rights Reserved. 
 * 
 * Unauthorized copying of this file, via any medium is strictly prohibited.   
 * Proprietary and confidential
 * 
 * Last Modified: 2015-9-22 16:41:26
 ******************************************************************************/
package cn.cmcc.online.smsapi.sdk.action;

import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Process;
import android.provider.CalendarContract;
import android.provider.CalendarContract.Events;
import android.text.ClipboardManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import cn.cmcc.online.smsapi.sdk.constant.Constant;
import cn.cmcc.online.smsapi.sdk.db.entity.IccidInfo;
import cn.cmcc.online.smsapi.sdk.db.entity.IccidInfoManager;
import cn.cmcc.online.smsapi.sdk.dex.DexUtil;
import cn.cmcc.online.smsapi.sdk.iccid.IccidLocationUtil;
import cn.cmcc.online.smsapi.sdk.log.LogManager;
import cn.cmcc.online.smsapi.sdk.net.NetUtil;
import cn.cmcc.online.smsapi.sdk.queue.SdkTaskQueue;
import cn.cmcc.online.smsapi.sdk.queue.TaskInfo;
import cn.cmcc.online.smsapi.sdk.threadpool.SmartSmsThreadPoolManager;
import cn.cmcc.online.smsapi.sdk.util.AppUtil;
import cn.cmcc.online.smsapi.sdk.util.ConversationManager;
import cn.cmcc.online.smsapi.sdk.util.DuoquUtils;
import cn.cmcc.online.smsapi.sdk.util.JsonUtil;
import cn.cmcc.online.smsapi.sdk.util.KeyManager;
import cn.cmcc.online.smsapi.sdk.util.LocalActionImpl;
import cn.cmcc.online.smsapi.sdk.util.StringUtils;
import cn.cmcc.online.smsapi.sdk.util.XyUtil;
import cn.cmcc.online.smsapi.sdk.util.ZFButil;
import cn.cmcc.online.smsapi.util.ParseManager;
import cn.cmcc.online.smsapi.util.SdkCallBack;
import cn.cmcc.online.smsapi.util.UUIDUtils;
/*SDK-674 hewengao 20161114 end*/
/**
 * SDK动作实现
 * 
 * @author Administrator
 * 
 */
public abstract class AbsSdkDoAction {
    final public static int SDK_EVENT_INIT_COMPLETE = 0;
    /* SDK-397 huangzhiqiang 20160526 start */
    final public static int SDK_EVENT_REMOVE_PUBINFO_CACHE = 10;
    /* SDK-397 huangzhiqiang 20160526 end */
    /* SDK-723 quyi 20170214 start */
    final public static int SDK_EVENT_UPDATE_PUBINFO_CACHE = 12;
    /* SDK-723 quyi 20170214 end */
    /*SDK-594 hewengao/20160819 start*/
    final public static int SDK_EVENT_LOAD_COMPLETE = 11;
    /*SDK-594 hewengao/20160819 end*/
    final public static int SDK_DOACTION_ERROR = -1;

    private static final String ACTION_SEND_SMS = "send_sms";
    private static final String ACTION_REPLY_SMS = "reply_sms";
    private static final String ACTION_ADD_ADDRBOOK = "add_addrbook";
    private static final String ACTION_COPY_CODE = "copy_code";
    private static final String ACTION_CALL_PHONE = "call_phone";
    private static final String ACTION_CALL = "call";
    private static final String ACTION_OPEN_URL = "open_url";
    private static final String ACTION_ADD_BOOKMARK = "add_bookmark";
    private static final String ACTION_ADD_CALANDER = "sdk_time_remind";
    private static final String ACTION_OPEN_CALANDER = "open_calendar";
    private static final String ACTION_ADD_ALARM = "add_alarm";
    private static final String ACTION_MAP_NAVIGATION = "open_map_browser";
    private static final String ACTION_SEND_EMAIL = "send_email";
    /*SDK-481 hewengao 20160613 start */
    public final static int CONFIG_VIEW_MANAGER_CLASS =1;
    public final static int CONFIG_WEB_ACTIVITY_CLASS =2;
    public final static int CONFIG_UI_CONFIG_CLASS =3;
    /*SDK-481 hewengao 20160613 end */
    /* SDK-561 huangzhiqiang 20160613 start */
    public final static int CONFIG_BEFORE_HAND_PARSE_SIZE = 4; 
    /* SDK-561 huangzhiqiang 20160613 end */
    
    /*SDK-621 zhaojiangwei 20160922 start */
    public final static int CONFIG_NEARBY_ACTIVITY_CLASS = 5;
    /*SDK-621 zhaojiangwei 20160922 start */
    
    /*ONEPLUSCII-98 songzhirong 20161226 start*/
    public final static int CONFIG_NOTIFY_ALL_ALGORITHM = 6;
    /*ONEPLUSCII-98 songzhirong 20161226 end*/
    
    /*SDK-490 hewengao 20160616 start */
    public final static int EXTEND_CONFIG_PARSE_MSG =1;
    /*SDK-490 hewengao 20160616 end */
    
    /* SDK-706 huangzhiqiang 20161226 begin */
    public final static int OPEN_TYPE_HIDDEN_BUTTON_IF_NOT_INSTALLED = 0;
    public final static int OPEN_TYPE_DOWNLOAD_BY_URL = 1;
    public final static int OPEN_TYPE_DOWNLOAD_BY_MARKET = 2;
    /* SDK-706 huangzhiqiang 20161226 end */
	
	 /** 位置运营商 */
    public static final int OPERATOR_UNKNOWN = -1;
    /** 中国移动 */
    public static final int OPERATOR_CMCC = 1;
    /** 中国联通 */
    public static final int OPERATOR_CUCC = 2;
    /** 中国电信 */
    public static final int OPERATOR_CTCC = 3;
    
    private int getSimIndex(String sim) {
        int simIndex = -1;
        if (sim != null) {
            try {
                simIndex = Integer.valueOf(sim);
            }
            catch (Throwable e) {
                // e.printStackTrace();
                /*SDK-550 hewengao 20160719 start*/
                LogManager.w(Constant.TAG, "getSimIndex: ", e);
                /*SDK-550 hewengao 20160719 end*/

            }
        }
        // LogManager.d("DuoquUtils", "getSimIndex: " + simIndex); 
        return simIndex;
    }

    /**
     * 获取卡位
     * 
     * @param actionMap
     * @return
     */
    private int getSimIndex(Map<String, String> actionMap) {
        if (actionMap != null) {
            String sim = actionMap.get("simIndex");
            return getSimIndex(sim);
        }
        return -1;
    }

    /**
     * 判断是否启用服务选择页
     * 
     * @param channel
     *            客户端渠道号
     * @return
     */
    private boolean isServiceChoose(String channel, String type) {
        /*SDK-550 hewengao 20160719 start*/
        int result = DexUtil.isServiceChoose(channel, type);
        /* GIONEE-375/yangzhi/2017.06.07---start--- */
        if ("15Du354QGIONEECARD".equals(channel)) {
            if ("WEB_TRAFFIC_ORDER".equalsIgnoreCase(type)) {
                return false;
            }
        }
        /* GIONEE-375/yangzhi/2017.06.07---end--- */
        if (result == Constant.SERVICE_TYPE_DISABLE) {
            return false;
        }
        else if (result < 0) {
            if ("VMhlWdEwVNEW_LENOVO".equals(channel)) {
                return false;
            }
            else if ("1i1BDH2wONE+".equals(channel)) {
                return false;
            }
            /*SDK-680 zhaojiangwei 20161117 start */
            else if("gOLrCBhQMEIZU2".equals(channel)){
                if("WEB_TRAFFIC_ORDER".equalsIgnoreCase(type) 
                        ||"RECHARGE".equalsIgnoreCase(type)
                        ||"zfb_repayment".equalsIgnoreCase(type)){
                    return false;
                }
            }
            else if("D6mKXM8MEIZU".equals(channel)){
                if("zfb_repayment".equalsIgnoreCase(type)){
                    return false;
                }
            }
            /*SDK-680 zhaojiangwei 20161117 end */
            /* HUAWEI-2500/yangzhi/2017.06.08---start--- */
            else if ("3GdfMSKwHUAWEI".equals(channel)||"7N4EhHawHUAWEI2".equals(channel)||"XHFBWgoQHUAWEI3".equals(channel)) {
                /* HUAWEI-2500/yangzhi/2017.06.08---end--- */
                if (!"repayment".equalsIgnoreCase(type) && !"zfb_repayment".equalsIgnoreCase(type)) {
                    return false;
                }
            }
        }
        /*SDK-550 hewengao 20160719 end*/
        return true;
    }

    /**
     * 解析动作参数数据
     * 
     * @param actionData
     * @return
     */
    JSONObject parseActionData(String actionData) {
        // actionData 解密

        if (actionData == null)
            return null;

        try {
            actionData = StringUtils.decode(actionData);
            return new JSONObject(actionData);
        }catch (Throwable e) {
            // e.printStackTrace();
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w(Constant.TAG, "parseActionData: ", e);
            /*SDK-550 hewengao 20160719 end*/
        }
        return null;
    }

    static String getPhoneNum(String phoneNum) {
        if (phoneNum != null) {
            String[] arr = phoneNum.split("__ARR__");
            for (String p : arr) {
                if ("null".equalsIgnoreCase(p))
                    continue;
                return p;
            }
        }
        return "";
    }

    /* SDK-404 hewengao 20160421 start */
    /**
     * 执行动作
     * 
     * @param ac
     *            界面上下文
     * @param actionData
     *            动作数据
     * @param actionMap
     *            动作扩展参数
     */
    @SuppressLint("DefaultLocale")
    public void doAction(Context ac, String actionData, Map<String, String> extend) throws Exception {
        /*SDK-429 hewengao 20160509 start*/
        JSONObject tempdata = null;
        /*SDK-429 hewengao 20160509 end*/
        /*SDK-431 songzhirong 20160530 start*/
        String uuid = UUIDUtils.uniqId();
        /*SDK-431 songzhirong 20160530 end*/
        try {
            if (StringUtils.isNull(actionData)) {
                throw new Exception("doAction  actionData is null");
            }
            /*SDK-429 hewengao 20160509 start*/
            tempdata = new JSONObject(actionData);
            /*SDK-429 hewengao 20160509 end*/
            if (tempdata != null && tempdata.get("uiType").equals("MENU")) {
                 /*SDK-431 songzhirong 20160530 start*/
                ConversationManager.saveLogIn(uuid,"cn.cmcc.online.smsapi.sdk.action.AbsSdkDoAction", "doAction",  ac,  actionData,  extend,tempdata);
                /*SDK-431 songzhirong 20160530 end*/
                actionData = tempdata.optString("menu_item_action_data");
                SdkTaskQueue.addTask(new TaskInfo(11, "phoneNum", tempdata.optString("phoneNum"), "companyNum",
                        tempdata.optString("companyNum"), "functionMode", tempdata.optString("menuCode")));
                /*SDK-431 songzhirong 20160530 start*/
                ConversationManager.saveLogOut(uuid,"cn.cmcc.online.smsapi.sdk.action.AbsSdkDoAction", "doAction",  ac,  actionData,  extend,tempdata);
                /*SDK-431 songzhirong 20160530 end*/
            }

        }
        catch (Throwable e) {
            // TODO: handle exception
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w(Constant.TAG, "doAction: ", e);
            /*SDK-550 hewengao 20160719 end*/
        }

        try {
            JSONObject data = parseActionData(actionData);
            if (data == null) {
                throw new Exception("please valid  actionData ");
            }
            /*SDK-429 hewengao 20160509 start*/
            if(tempdata != null){
                data.put("conversation_num", tempdata.optString("phoneNum"));
                data.put("conversation_pub", tempdata.optString("companyNum"));
                data.put("conversation_menu", tempdata.optString("menuCode"));
            }
            /*SDK-429 hewengao 20160509 end*/
            exectueAction(ac, data, extend);

        }
        catch (Throwable e) {
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w(Constant.TAG, "doAction: ", e);
            /*SDK-550 hewengao 20160719 end*/
        }
    }

    

    /**
     * 执行动作
     * 
     * @param ac
     *            界面上下文
     * @param actionData
     *            已解密的动作参数数据 动作数据
     * @param actionMap
     *            动作扩展参数
     */
    @SuppressLint("DefaultLocale")
    public void exectueAction(Context ac, JSONObject data, Map extend) throws Exception {
        String uuid = UUIDUtils.uniqId();
        try {
            ConversationManager.saveLogIn(uuid,"cn.cmcc.online.smsapi.sdk.action.AbsSdkDoAction", "exectueAction",   ac,  data,  extend);

            String actionType = data.optString("type");

            if (StringUtils.isNull(actionType)) {

                throw new Exception("actionType is  null");
            }
             /*SDK-382 /songzhirong/2016.05.17---start---*/
            if(actionType.toLowerCase().startsWith("conversation_")){
                doConversationAction(ac, actionType, data, extend);
            }
             /*SDK-382 /songzhirong/2016.05.17---end---*/
            else if (actionType.toLowerCase().startsWith("ex_")) {
                doExAction(ac, actionType, data, extend);
            }
            else if (ACTION_ADD_ADDRBOOK.equalsIgnoreCase(actionType)) {
                String phone = null;
                String email = null;
                String url = null;
                String filed = (String) JsonUtil.getValueFromJsonObject(data, "field");
                if (filed.equalsIgnoreCase("phone")) {
                    phone = (String) JsonUtil.getValueFromJsonObject(data, "content");
                }
                if (filed.equalsIgnoreCase("email")) {
                    email = (String) JsonUtil.getValueFromJsonObject(data, "content");
                }
                /*SDK-670 zhaojiangwei 20161108 start */
                if (filed.equalsIgnoreCase("url")) {
                    url = (String) JsonUtil.getValueFromJsonObject(data, "content");
                }
                /*SDK-670 zhaojiangwei 20161108 end */
                addContact(ac, null, phone, email, url, extend);
            }
            else if (ACTION_REPLY_SMS.equalsIgnoreCase(actionType)) {// 回复短信

                String code = (String) JsonUtil.getValueFromJsonObject(data, "send_code");
                String phone = (String) JsonUtil.getValueFromJsonObject(data, "phone");
                if (StringUtils.isNull(phone) || "null".equalsIgnoreCase(phone)) {
                    /* SDK-404 hewengao 20160422 start */
                    if (extend != null) {
                        phone = (String) extend.get("phoneNum");
                    }
                    /* SDK-404 hewengao 20160422 start */
                }
                sendSms(ac, phone, code, getSimIndex(extend), extend);
            }
            else if (ACTION_SEND_SMS.equalsIgnoreCase(actionType)) {// 发送短信
                String code = (String) JsonUtil.getValueFromJsonObject(data, "send_code");
                String phone = (String) JsonUtil.getValueFromJsonObject(data, "phone");
                sendSms(ac, phone, code, getSimIndex(extend), extend);
            }
            else if (ACTION_ADD_ALARM.equalsIgnoreCase(actionType)) {
                String time = (String) JsonUtil.getValueFromJsonObject(data, "time");
                if (!TextUtils.isEmpty(time)) {
                    /*UIX标准方案UIX-207 kedeyuan 2016.06.17 start*/
                    String fmtTime = ActionHelper.convertTimeToString(time);
                    /*UIX标准方案UIX-207 kedeyuan 2016.06.17 end*/
                    
                    String[] tmps = fmtTime.split(":");
                    if (tmps != null && tmps.length == 2) {
                        int hour = Integer.parseInt(tmps[0]);
                        int minute = Integer.parseInt(tmps[1]);
                        addAlarm(ac, hour, minute, extend);
                    }
                }
            }
            else if (ACTION_OPEN_CALANDER.equalsIgnoreCase(actionType)) {
                String date = (String) JsonUtil.getValueFromJsonObject(data, "date");
                long time = ActionHelper.convertDate(date);
                viewCalendar(ac, time, extend);
            }
            else if (ACTION_ADD_BOOKMARK.equalsIgnoreCase(actionType)) {
                String url = (String) JsonUtil.getValueFromJsonObject(data, "url");
                addBookMark(ac, url, extend);
            }
            else if(ACTION_OPEN_URL.equalsIgnoreCase(actionType)){
                String url = (String) JsonUtil.getValueFromJsonObject(data, "url");
                openUrl(ac, url, data);
            }
            else if (ACTION_COPY_CODE.equalsIgnoreCase(actionType)) {
                String code = (String) JsonUtil.getValueFromJsonObject(data, "code");
                copyCode(ac, code,extend);
            }
            else if (ACTION_CALL.equalsIgnoreCase(actionType) || ACTION_CALL_PHONE.equalsIgnoreCase(actionType)) {
                String phoneNum = null;
                if (data.has("phone")) {
                    phoneNum = data.getString("phone");
                }
                else if (data.has("phoneNum")) {
                    phoneNum = data.getString("phoneNum");
                }
                callPhone(ac, getPhoneNum(phoneNum), getSimIndex(extend));
            }
            else if (ACTION_SEND_EMAIL.equalsIgnoreCase(actionType)) {
                String receiver = (String) JsonUtil.getValueFromJsonObject(data, "email");
                sendEmailTo(ac, receiver, extend);
            }
            else if (ACTION_MAP_NAVIGATION.equalsIgnoreCase(actionType)) {
                // 打开地图
                String address = (String) JsonUtil.getValueFromJsonObject(data, "address");
                openMapOnBrowser(ac, address);
            }
            else if ("access_url".equalsIgnoreCase(actionType) || "open_url".equalsIgnoreCase(actionType)) {
                String url = (String) JsonUtil.getValueFromJsonObject(data, "url");
                openUrl(ac, url, data);
            }
            else if ("down_url".equalsIgnoreCase(actionType)) {
                String url = (String) JsonUtil.getValueFromJsonObject(data, "url");
                downLoadUrl(ac, url);// 下载
            }
            else if ("download".equalsIgnoreCase(actionType)) {
                // 需要下载的应用包名
                String appName = (String) JsonUtil.getValueFromJsonObject(data, "appName");
                if (StringUtils.isNull(appName)) {
                    appName = (String) JsonUtil.getValueFromJsonObject(data, "extend");
                }
                String url = (String) JsonUtil.getValueFromJsonObject(data, "url");

                if (extend == null) {
                    extend = new HashMap<String, String>();
                }
                // 传递菜单名称，用于标题栏显示菜单名称
                extend.put("menuName", (String) JsonUtil.getValueFromJsonObject(data, "menuName"));
                downLoadApp(ac, appName, url, extend);// 下载
            }
            else if ("weibo_url".equalsIgnoreCase(actionType)) {
                String url = (String) JsonUtil.getValueFromJsonObject(data, "url");
                openWeiBoUrl(ac, url);// 打开微博
            }
            else if ("map_site".equalsIgnoreCase(actionType) || "open_map".equalsIgnoreCase(actionType)) {
                // 打开地图
                String address = (String) JsonUtil.getValueFromJsonObject(data, "address");
                openMap(ac, address);
            }
            else if ("recharge".equalsIgnoreCase(actionType)) {

                if (isServiceChoose(KeyManager.channel, actionType)) {
                    // 启用服务选择页
                    serviceChoose(ac, data, "WEB_RECHARGE_CHOOSE", extend);

                }
                else {
                    // 不应该两个方法都调，应调用参数多的，不要让第三方。也要重写两个方法。第三方只需要重写一个方法即可。
                    // if (extend != null) {
                    int code = recharge(ac, data, extend);
                    if (code == SDK_DOACTION_ERROR) {
                        serviceChoose(ac, data, "WEB_RECHARGE_CHOOSE", extend);
                    }
                    // } else {
                    // 充值
                    // recharge(ac, data);
                    // }
                }
            }
            else if ("repayment".equalsIgnoreCase(actionType)) {

                if (isServiceChoose(KeyManager.channel, actionType)) {

                    // 启用服务选择页
                    serviceChoose(ac, data, "WEB_REPAYMENT_CHOOSE", extend);

                }
                else {
                    // 还款
                    String appName = data.getString("appName");
                    if (checkHasAppName(ac, appName)) {
                        repayment(ac, data);
                    }
                    else {
                        data.put("type", "WEB_REPAYMENT");
                        /*SDK-473 hewengao 20160603 start */
                        startWebActivity(ac, data, "WEB_REPAYMENT", null, extend);
                        /*SDK-473 hewengao 20160603 start */
                        // String url = data.getString("appDownUrl");
                        // downLoadApp(ac, appName, url, extend);
                        // downLoadUrl(ac, url);
                    }
                }

            }
            else if ("zfb_recharge".equalsIgnoreCase(actionType)) {
                if (isServiceChoose(KeyManager.channel, actionType)) {
                    // 启用服务选择页
                    serviceChoose(ac, data, "WEB_RECHARGE_CHOOSE", extend);
                }
                else {
                    zfbRecharge(ac, data, extend);
                }

            }
            else if ("zfb_repayment".equalsIgnoreCase(actionType)) {
                if (isServiceChoose(KeyManager.channel, actionType)) {
                    // 启用服务选择页
                    serviceChoose(ac, data, "WEB_REPAYMENT_CHOOSE", extend);
                }
                else {
                    zfbRepayment(ac, data, extend);
                }

            }
            else if ("open_app".equalsIgnoreCase(actionType)) {
                // 打开应用,依据包名或依据网址
                String appName = data.getString("appName");
                String jsExtend = data.optString("extendVal");
                if (!StringUtils.isNull(jsExtend)) {
                    try {
                        jsExtend = jsExtend.trim();
                        if (jsExtend.startsWith("{")) {/*
                                                         * // 新版本的open_app
                                                         * JSONObject js = new
                                                         * JSONObject(jsExtend);
                                                         * String appViewUrl =
                                                         * js
                                                         * .optString("viewUrl"
                                                         * ); boolean success =
                                                         * LocalActionImpl
                                                         * .startAppActionViewByURL
                                                         * (ac,
                                                         * js.optString("appName"
                                                         * ), appViewUrl, js);
                                                         * if (!success) {
                                                         * String appDownUrl =
                                                         * data
                                                         * .optString("appDownUrl"
                                                         * ); // 未打开成功，下载对应的应用。
                                                         * downLoadUrl(ac,
                                                         * appDownUrl); }
                                                         */
                            openAppView(ac, data, jsExtend);
                        }
                        else {
                            // 如果是老版本的open_app
                            if (StringUtils.isNull(appName)) {
                                appName = jsExtend;
                            }
                            if (!StringUtils.isNull(appName)) {
                                openAppByAppName(ac, appName, data.optString("appDownUrl"));
                            }
                        }
                    }
                    catch (Throwable e) {
                        /*SDK-550 hewengao 20160719 start*/
                        LogManager.w(Constant.TAG, "AbsSdkDoAction openApp: ", e);
                        /*SDK-550 hewengao 20160719 end*/
                    }
                }
                else if (!StringUtils.isNull(appName)) {
                    openAppByAppName(ac, appName, data.optString("appDownUrl"));
                }

            }
            else if ("open_app_view".equalsIgnoreCase(actionType)) {
                // 打开某应用的指定界面
                String extendStr = data.optString("extend");
                if (StringUtils.isNull(extendStr)) {
                    return;
                }
                try {
                    JSONObject js = new JSONObject(extendStr);
                    String appName = js.optString("appName");
                    String appViewUrl = js.optString("viewUrl");
                    boolean success = LocalActionImpl.startAppActionViewByURL(ac, appName, appViewUrl, data);
                    if (!success) {
                        String appDownUrl = data.optString("appDownUrl");
                        // 未打开成功，下载对应的应用。
                        downLoadUrl(ac, appDownUrl);
                    }
                }
                catch (Throwable e) {
                    // e.printStackTrace();
                    /*SDK-550 hewengao 20160719 start*/
                    LogManager.w(Constant.TAG, "open_app_view: ", e);
                    /*SDK-550 hewengao 20160719 end*/

                }
            }
            else if ("time_remind".equalsIgnoreCase(actionType)) {
                try {
                    /* SDK-404 hewengao 20160422 start */
                    String phoneNum = (String) extend.get("phoneNum");
                    String content = (String) extend.get("content");
                    /* SDK-404 hewengao 20160422 end */
                    Map<String, Object> result = ParseManager.parseMsgToMap(Constant.getContext(), phoneNum, "",
                            content, null);
                    /* SDK-404 hewengao 20160422 start */
                    String msgId = (String) extend.get("msgId");
                    /* SDK-404 hewengao 20160422 end */
                    doRemind(ac, msgId, result);

                }
                catch (Throwable e) {
                    // e.printStackTrace();
                    /*SDK-550 hewengao 20160719 start*/
                    LogManager.w(Constant.TAG, "time_remind: ", e);
                    /*SDK-550 hewengao 20160719 end*/
                }
            }
            else if ("sdk_time_remind".equalsIgnoreCase(actionType)) {
                try {
                    String msgId = "";
                    if (extend != null && !extend.isEmpty()) {
                        /* SDK-404 hewengao 20160422 start */
                        msgId = (String) extend.get("msgId");
                        /* SDK-404 hewengao 20160422 end */
                    }
                    String title = (String) JsonUtil.getValueFromJsonObject(data, "title");
                    String eventLocation = (String) JsonUtil.getValueFromJsonObject(data, "eventLocation");
                    String description = (String) JsonUtil.getValueFromJsonObject(data, "description");
                    String startTime = (String) JsonUtil.getValueFromJsonObject(data, "startTime");
                    String endTime = (String) JsonUtil.getValueFromJsonObject(data, "endTime");
                    /* SDK-408 zhengxiaobo 20160426 begin */
                    String remind = (String) JsonUtil.getValueFromJsonObject(data, "remind");
                    /* SDK-408 zhengxiaobo 20160426 end */
                    doRemind(ac, msgId, title, eventLocation, description, startTime, endTime,remind, extend);
                }
                catch (Throwable e) {
                    // e.printStackTrace();
                    /*SDK-550 hewengao 20160719 start*/
                    LogManager.w(Constant.TAG, "sdk_time_remind: ", e);
                    /*SDK-550 hewengao 20160719 end*/
                }
            }
            else if ("del_msg".equalsIgnoreCase(actionType)) {
                try {
                    String msgId = (String) JsonUtil.getValueFromJsonObject(data, "msgId");
                    deleteMsgForDatabase(ac, msgId);
                    finishActivity(ac, extend);
                    // ac.finish();
                }
                catch (Throwable e) {
                    // TODO: handle Throwable
                    /*SDK-550 hewengao 20160719 start*/
                    LogManager.w(Constant.TAG, "2sdk_time_remind: ", e);
                    /*SDK-550 hewengao 20160719 end*/
                }
            }
            else if ("open_map_list".equalsIgnoreCase(actionType)) {
                try {
                    String address = (String) JsonUtil.getValueFromJsonObject(data, "address");
                    /* SDK-404 hewengao 20160422 start */
                    String latitude = (String) extend.get("latitude");
                    String longitude = (String) extend.get("longitude");
                    /* SDK-404 hewengao 20160422 end */
                    // if ("3GdfMSKwHUAWEI".equals(KeyManager.channel)) {
                    // openMap(ac, address);
                    // data.put("type", "WEB_NEAR_SITE");// 附近网点
                    // PopupUtil.startWebActivity(ac, data, "WEB_NEAR_SITE","");
                    // openMap(ac, address);
                    // } else {
                    if ("3GdfMSKwHUAWEI".equals(KeyManager.channel)) {
                        extend.put("menuName", (String) JsonUtil.getValueFromJsonObject(data, "menuName"));
                        nearSite(ac, address, latitude, longitude, extend);
                    }
                    else {
                        nearSite(ac, address, latitude, longitude);
                    }
                    // }
                }
                catch (Throwable e) {
                    // TODO: handle Throwable
                    /*SDK-550 hewengao 20160719 start*/
                    LogManager.w(Constant.TAG, "3sdk_time_remind: ", e);
                    /*SDK-550 hewengao 20160719 end*/
                }
            }
            else if ("open_map_browser".equalsIgnoreCase(actionType)) {
                // 打开地图
                String address = (String) JsonUtil.getValueFromJsonObject(data, "address");
                openMapOnBrowser(ac, address);
            }
            else if ("pay_water_gas".equalsIgnoreCase(actionType)) {
                int code = payWaterGas(ac, data, extend);
                if (code == SDK_DOACTION_ERROR) {
                    // 走服务选择页
                }
            }
            else if (actionType.toUpperCase().startsWith("WEB_")) {

                if ("WEB_TRAFFIC_ORDER".equalsIgnoreCase(actionType)) {
                    if (isServiceChoose(KeyManager.channel, actionType)) {
                        serviceChoose(ac, data, "WEB_TRAFFIC_CHOOSE", extend);
                    }
                    else {
                        int code = orderTraiffc(ac, data, extend);
                        if (code == SDK_DOACTION_ERROR) {
                            serviceChoose(ac, data, "WEB_TRAFFIC_CHOOSE", extend);
                        }
                    }
                }
                else {
                    String phoneNum = "";
                    if (extend != null && !extend.isEmpty()) {
                        /* SDK-404 hewengao 20160422 start */
                        if (StringUtils.isNull(phoneNum)) {
                            phoneNum = (String) extend.get("phone");
                        }
                        if (StringUtils.isNull(phoneNum)) {
                            phoneNum = (String) extend.get("phoneNum");
                        }
                        /* SDK-404 hewengao 20160422 end */
                    }

                    if (extend != null) {
                        String simIndex = null;
                        /* SDK-404 hewengao 20160422 start */
                        simIndex = (String) extend.get("simIndex");
                        /* SDK-404 hewengao 20160422 end */
                        if (simIndex != null) {
                            try {
                                data.put("simIndex", simIndex);
                            }
                            catch (JSONException e) {
                                // TODO Auto-generated catch block
                                // e.printStackTrace();
                                /*SDK-550 hewengao 20160719 start*/
                                LogManager.w(Constant.TAG, "WEB_TRAFFIC_ORDER: ", e);
                                /*SDK-550 hewengao 20160719 end*/
                            }
                        }
                    }
                    startWebActivity(ac, data, actionType, phoneNum, extend);
                }
            }
            else if ("display_scene_result".equalsIgnoreCase(actionType)) {
                startDisplaySceneActivity(ac, data, actionType);
            }
            else if ("wizard_service".equalsIgnoreCase(actionType)) {
                /* SDK-383 xusongzhou 20160419 start */
                startWizardService(ac, data, extend);
                /* SDK-383 xusongzhou 20160419 end */
            }
            else {
                // 执行未来的未知类型
                LocalActionImpl.doActionOnImpl(ac, actionType, data);
            }
        }
        catch (Throwable e) {
            // TODO: handle Throwable
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w("XIAOYUAN", "doAction ERROR: ", e);
            /*SDK-550 hewengao 20160719 end*/
        }
        finally {
            /*SDK-431 songzhirong 20160530 start*/
            ConversationManager.saveLogOut(uuid,"cn.cmcc.online.smsapi.sdk.action.AbsSdkDoAction", "exectueAction",   ac,  data,  extend);
            /*SDK-431 songzhirong 20160530 end*/
            try {
                if (extend != null) {
	                /* SDK-404 hewengao 20160422 start */
	                String viewType = (String) extend.get("viewType");
	                if ("0".equals(viewType)) {
	                    String phoneNum = "";
	                    if (!extend.isEmpty()) {
	                        if (StringUtils.isNull(phoneNum)) {
	                            phoneNum = (String) extend.get("phone");
	                        }
	                        if (StringUtils.isNull(phoneNum)) {
	                            phoneNum = (String) extend.get("phoneNum");
	                        }
	                    }
	                    finishActivity(ac, extend);
	                }
	                /* SDK-404 hewengao 20160422 end */
                }
            }
            catch (Throwable e2) {
                // TODO: handle Throwable
                /*SDK-550 hewengao 20160719 start*/
                LogManager.e(Constant.TAG, "doAction ERROR: ", e2);
                /*SDK-550 hewengao 20160719 end*/
            }
        }
    }

    /* SDK-404 hewengao 20160421 end */

    public void openAppView(Context ac, JSONObject data, String jsExtend) {
        try {
            // 新版本的open_app
            JSONObject js = new JSONObject(jsExtend);
            String appViewUrl = js.optString("viewUrl");
            boolean success = LocalActionImpl.startAppActionViewByURL(ac, data.optString("appName"), appViewUrl, js);
            if (!success) {
                String appDownUrl = data.optString("appDownUrl");
                /* SDK-706 huangzhiqiang 20161226 begin */
                // 未打开成功，下载对应的应用。
                downLoadUrl(ac, appDownUrl, data);
                /* SDK-706 huangzhiqiang 20161226 end */
            }
        }
        catch (Throwable e) {
            // TODO: handle exception
        }

    }

    public static void startDisplaySceneActivity(Context context, JSONObject jsobj, String actionType) {
        try {

            Intent intent2 = new Intent();
            intent2.putExtra("actionType", actionType);
            if (jsobj != null) {
                intent2.putExtra("JSONDATA", jsobj.toString());
            }
            intent2.setClassName(context, "cn.com.xy.sms.sdk.ui.popu.web.SdkDisplaySceneActivity");
            intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent2);
        }
        catch (Throwable e) {

        }
    }

    /**
     * 下载
     * 
     * @param context
     * @param url
     */
    public void openWeiBoUrl(Context context, String url) {
        openUrl(context, url, null);
    }

    /**
     * 下载
     * 
     * @param context
     * @param url
     */
    public void downLoadUrl(Context context, String url) {
    	/*RM-1419 songzhirong 20170410 start*/
//        operUrlOnBrowser(context, url);
        openUrl(context, url, null);
    	/*RM-1419 songzhirong 20170410 end*/
    }

    /* SDK-734 songzhirong 20170317 begin */
    /* SDK-706 huangzhiqiang 20161226 begin */
    public void downLoadUrl(Context ctx, String url, JSONObject actionData) {
        if (actionData == null) {
            downLoadUrl(ctx, url);
            return;
        }
        int openType = actionData.optInt("openType", -1);
        switch (openType) {
            case AbsSdkDoAction.OPEN_TYPE_DOWNLOAD_BY_MARKET:
                String appName = actionData.optString("appName");
                downAppByAppMarket(ctx, appName);
                break;
            default:
                downLoadUrl(ctx, url);
                break;
        }
    }
    private void downAppByAppMarket(Context context, String appName) {
        if(context == null){
            return;
        }
        Uri uri = Uri.parse("market://details?id=" + appName);
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }
    /* SDK-706 huangzhiqiang 20161226 end */
    /* SDK-734 songzhirong 20170317 end */


    /**
     * 下载应用
     * 
     * @param context
     * @param appName
     *            需要一载的包名
     * @param url
     *            官网下载地址
     * @param extend
     *            扩展参数
     */
    public void downLoadApp(Context context, String appName, String url, Map<String, String> extend) {
        boolean runsuccess = false;
        try {
            if (!StringUtils.isNull(appName)) {
                if (checkHasAppName(context, appName)) {
                    openAppByAppName(context, appName);
                }
                else {
                    Uri uri = Uri.parse("market://details?id=" + appName);
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    context.startActivity(intent);
                }
                runsuccess = true;
            }
        }
        catch (Throwable e) {
            // Toast.makeText(Constant.getContext(),
            // " 2downLoadApp: "+e.getMessage(), Toast.LENGTH_LONG).show();
            runsuccess = false;
        }
        if (runsuccess == false) {
            JSONObject jsobj = null;
            if (extend != null && extend.containsKey("menuName")) {
                jsobj = new JSONObject();
                try {
                    // 传递菜单名称，用于标题栏显示菜单名称
                    jsobj.put("menuName", extend.get("menuName"));
                }
                catch (JSONException ex) {
                    // ex.printStackTrace();
                    /*SDK-550 hewengao 20160719 start*/
                    LogManager.w(Constant.TAG, "downLoadApp: ", ex);
                    /*SDK-550 hewengao 20160719 end*/
                }
            }
            openUrl(context, url, jsobj);
        }
    }

    void operUrlOnBrowser(Context context, String url) {
        try {
            if (!StringUtils.isNull(url)) {
                url = url.trim();
                if (!url.startsWith("http")) {
                    url = "http://" + url;
                }
            }
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            setNewTaskIfNeed(context, intent);
            context.startActivity(intent);
            // context.finish();
        }
        catch (Throwable e) {
            // e.printStackTrace();
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w(Constant.TAG, "operUrlOnBrowser: ", e);
            /*SDK-550 hewengao 20160719 end*/
        }
    }

    // /**
    // * 打开网址
    // *
    // * @param context
    // * @param url
    // */
    // public void openUrl(Context ac, String url) {
    // boolean isOpened = false;
    // try {
    // JSONObject jsobj = new JSONObject();
    // if (!StringUtils.isNull(url)) {
    // url = url.replaceAll("&amp;", "&");
    // url = url.trim();
    // if (!url.startsWith("http")) {
    // url = "http://" + url;
    // }
    // }
    // jsobj.put("url", url);
    // isOpened = PopupUtil.startWebActivity(ac, jsobj, "WEB_URL", "");
    // } catch (JSONException e) {
    // // TODO Auto-generated catch block
    // e.printStackTrace();
    // }
    // if (isOpened == false) {
    // operUrlOnBrowser(ac, url);
    // }
    // }
    /**
     * 打开网址
     * 
     * @param context
     * @param url
     */
    public void openUrl(Context ac, String url, JSONObject jsobj) {
        openUrl(ac, url, jsobj, null);
    }

    /**
     * 打开网址
     * 
     * @param context
     * @param url
     */
    public void openUrl(Context ac, String url, JSONObject jsobj, Map<String, String> extend) {
        boolean isOpened = false;
        try {
            if (jsobj == null) {
                jsobj = new JSONObject();
            }

            if (!StringUtils.isNull(url)) {
                url = url.replaceAll("&amp;", "&");
                url = url.trim();
                if (!url.startsWith("http")) {
                    url = "http://" + url;
                }
            }
            jsobj.put("url", url);
             /*SDK-473 hewengao 20160603 start */
            isOpened = startWebActivity(ac, jsobj, "WEB_URL", "", extend);
             /*SDK-473 hewengao 20160603 end */
        }
        catch (JSONException e) {
            // TODO Auto-generated catch block
            // e.printStackTrace();
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w(Constant.TAG, "openUrl: ", e);
            /*SDK-550 hewengao 20160719 end*/
        }
        if (isOpened == false) {
            operUrlOnBrowser(ac, url);
        }
    }

    public void copyCode(Context context, String code, Map<String, String> exntend) {
        ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
        cmb.setText(code);
        Toast.makeText(context, "已复制到剪贴板", Toast.LENGTH_LONG).show();
    }

    public void nearSite(Context context, String address, String latitude, String longitude) {
        nearSite(context, address, latitude, longitude, null);
    }

    public void nearSite(Context context, String address, String latitude, String longitude, Map<String, String> extend) {

        Intent intent = new Intent();
        /*SDK-621 20160922 zhaojiangwei start */
        String nearActivityClass =  DuoquUtils.getSdkDoAction().getConfig(AbsSdkDoAction.CONFIG_NEARBY_ACTIVITY_CLASS, null);
        if (StringUtils.isNull(nearActivityClass)) {
            nearActivityClass = "cn.com.xy.sms.sdk.ui.popu.web.NearbyPointList";
        }
        intent.setClassName(context, nearActivityClass);
        /*SDK-621 20160922 zhaojiangwei end */
        
        intent.putExtra("address", address);
        intent.putExtra("locationLatitude", latitude);
        intent.putExtra("locationLongitude", longitude);
        if (extend != null && extend.containsKey("menuName")) {
            intent.putExtra("menuName", extend.get("menuName"));
        }
        setNewTaskIfNeed(context, intent);
        context.startActivity(intent);

        // String lon=null;
        // String lat=null;
        // if(!StringUtils.isNull(latitude)&&!StringUtils.isNull(longitude)){//实现扩展参数的经纬度
        //
        // lat=latitude;
        // lon=longitude;
        //
        // }else{
        // ProgressDialog dialog = new ProgressDialog(context);
        // dialog.setMessage("正在定位...");
        // dialog.setCancelable(true);
        // dialog.show();
        // String jsonLocation=getLocation(context);
        // dialog.dismiss();
        // try {
        //
        // JSONObject obj=new JSONObject(jsonLocation);
        // lat=obj.optString("latitude");
        // lon=obj.optString("longitude");
        // } catch (JSONException e) {
        // // TODO Auto-generated catch block
        // e.printStackTrace();
        // }
        // }
        // if(StringUtils.isNull(lon)||StringUtils.isNull(lat)){//经纬度为空
        // openMap(context,address);
        // return;
        // }else{//经纬度不为空
        // NearbyPointUtil t=new NearbyPointUtil(context);
        // t.sendMapQueryUrl(address, lat, lon);
        // }
    }

    /**
     * 下载
     * 
     * @param context
     * @param url
     */
    public void nearList(Context context, String url) {
        operUrlOnBrowser(context, url);
    }

    // /**
    // * 打开地图
    // *
    // * @param context
    // * @param url
    // */
    // public void openMap(Activity context, String address) {
    // LogManager.i("openMap", "address=" + address);
    // try {
    // if (!StringUtils.isNull(address)) {
    // Intent intent = new Intent(Intent.ACTION_VIEW);
    // intent.setData(Uri.parse("geo:0,0?q=" + address));
    // context.startActivity(intent);
    // context.finish();
    // }
    // } catch (Throwable e) {
    // e.printStackTrace();
    // try {
    // if (!StringUtils.isNull(address)) {
    // Uri uri = Uri
    // .parse("http://api.map.baidu.com/geocoder?address="
    // + address + "&output=html&src=xiaoyuan|多趣");
    // Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    // context.startActivity(intent);
    // context.finish();
    // }
    // } catch (Throwable e2) {
    // e2.printStackTrace();
    // }
    //
    // }
    // }
    public void openMap(Context context, String title, String address, double lon, double lat) {
        // TODO Auto-generated method stub
        // LogManager.i("openMap", "address=" + address);
        // LogManager.i("openMap", "lon=" + address + ",lat=" + lat);
        try {
            if (!StringUtils.isNull(title)) {
                title = URLEncoder.encode(title, "utf-8");
            }
            else {
                title = "";
            }
            // LogManager.i("openMap", "new address=" + address);

            if (!StringUtils.isNull(address)) {
                address = address.replace(" ", ",").replace("（", ",").replace("(", ",").replace("，", ",")
                        .replace("）", "").replace(")", "").replace("?", "").replace("&", "").replace("#", "").trim();
                address = URLEncoder.encode(address, "utf-8");

                // 尝试调用本机地图软件客户端
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("geo:" + lat + "," + lon + "?q=" + address));
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);
                // context.finish();
            }
        }
        catch (Throwable e) {
            // e.printStackTrace();
            /*SDK-550 hewengao 20160719 start*/
            LogManager.e(Constant.TAG, "openMap: ", e);
            /*SDK-550 hewengao 20160719 end*/
            try {
                if (!StringUtils.isNull(address)) {
                    String uriStr = "";
                    if (lon != 0 && lat != 0) {
                        // 地图标点功能，调用该接口可调起PC或web地图，且在指定坐标点上显示点的名称和内容信息。
                        uriStr = "http://api.map.baidu.com/marker?location=" + lat + "," + lon + "&title=" + title
                                + "&content=" + address;
                    }
                    else {
                        // 地址解析，调用该接口可以在调起百度地图时，当前页面显示地址对应的坐标点。
                        uriStr = "http://api.map.baidu.com/geocoder?address=" + address;
                    }
                    Uri uri = Uri.parse(uriStr + "&output=html&src=xiaoyuan|多趣");
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    context.startActivity(intent);
                    // context.finish();
                }
                else if (lon != 0 && lat != 0) {
                    // 反向地址解析，调用该接口可调起PC或Web百度地图，经过逆地理编码后，以标注形式显示位置和地址信息。
                    Uri uri = Uri.parse("http://api.map.baidu.com/geocoder?location=" + lat + "," + lon
                            + "&coord_type=gcj02&output=html&src=xiaoyuan|多趣");
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    context.startActivity(intent);
                }
            }
            catch (Throwable e2) {
                // e2.printStackTrace();
                /*SDK-550 hewengao 20160719 start*/
                LogManager.w(Constant.TAG, "openMap: ", e2);
                /*SDK-550 hewengao 20160719 end*/
            }

        }
    }

    /**
     * 打开地图
     * 
     * @param context
     * @param url
     */
    public void openMap(Context context, String address) {
        openMap(context, null, address, 0, 0);
    }

    /**
     * 通过浏览器打开地图
     * 
     * @param context
     * @param url
     */
    public void openMapOnBrowser(Context context, String address) {
        openMapOnBrowser(context, null, address, 0, 0);
    }

    /**
     * 通过浏览器打开地图
     * 
     * @param context
     * @param url
     */
    public void openMapOnBrowser(Context context, String title, String address, double lon, double lat) {
        try {
            if (!StringUtils.isNull(address)) {
                String uriStr = "";
                if (lon != 0 && lat != 0) {
                    // 地图标点功能，调用该接口可调起PC或web地图，且在指定坐标点上显示点的名称和内容信息。
                    uriStr = "http://api.map.baidu.com/marker?location=" + lat + "," + lon + "&title=" + title
                            + "&content=" + address;
                }
                else {
                    // 地址解析，调用该接口可以在调起百度地图时，当前页面显示地址对应的坐标点。
                    uriStr = "http://api.map.baidu.com/geocoder?address=" + address;
                }
                Uri uri = Uri.parse(uriStr + "&output=html&src=xiaoyuan|多趣");
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);
                // context.finish();
            }
            else if (lon != 0 && lat != 0) {
                // 反向地址解析，调用该接口可调起PC或Web百度地图，经过逆地理编码后，以标注形式显示位置和地址信息。
                Uri uri = Uri.parse("http://api.map.baidu.com/geocoder?location=" + lat + "," + lon
                        + "&coord_type=gcj02&output=html&src=xiaoyuan|多趣");
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);
            }
        }
        catch (Throwable e2) {
            // e2.printStackTrace();
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w(Constant.TAG, "openMapOnBrowser: ", e2);
            /*SDK-550 hewengao 20160719 end*/
        }

    }

    /**
     * 还款服务选择
     * 
     * @param context
     * @param data
     * @throws JSONException
     */
    private void serviceChoose(Context context, JSONObject data, String serviceType, Map<String, String> extend)
            throws JSONException {

        if (data == null) {
            data = new JSONObject();
        }
        // JsonUtil.JSONCombine(data, new JSONObject(extend));

        data.put("extend", new JSONObject(extend));
        data.put("type", serviceType);
        if (extend.containsKey("exphone")) {
            data.put("exphone", extend.get("exphone"));
        }
        if (extend.containsKey("simIndex")) {
            data.put("simIndex", extend.get("simIndex"));
        }
         /*SDK-473 hewengao 20160603 start */
        startWebActivity(context, data, serviceType, null, extend);
         /*SDK-473 hewengao 20160603 start */

    }

    /**
     * 执行服务
     * 
     * @param context
     * @param data
     */
    public void toService(Context context, String actionType, JSONObject data) {
        Map<String, String> extend = new HashMap<String, String>();
        try {
        	/*SDK-646 zhaojiangwei 20161122 start */
        	if (data!=null) {
        	/*SDK-646 zhaojiangwei 20161122 end */	
        		 try {
                     if (data.has("actionName")) {
                         extend.put("actionName", data.optString("actionName"));
                     }
                     if (data.has("otherPackageName")) {
                         extend.put("otherPackageName", data.optString("otherPackageName"));
                     }
                     if (data.has("extend")) {
                         String extendStr = data.optString("extend");
                         JsonUtil.putJsonToMap(new JSONObject(extendStr), extend);
                     }
                 }
                 catch (Throwable e) {
                     /*SDK-550 hewengao 20160719 start*/
                     LogManager.w("xiaoyuan", "AbsSdkDoAction.toService ", e);
                     /*SDK-550 hewengao 20160719 end*/
                 }	
			}
            String type = data.optString("type");
            if (!StringUtils.isNull(type)) {
                if (type.toUpperCase().startsWith("WEB_")) {
                    String phoneNum = "";
                    if (extend != null && !extend.isEmpty()) {
                        if (StringUtils.isNull(phoneNum)) {
                            phoneNum = extend.get("phone");
                        }
                        if (StringUtils.isNull(phoneNum)) {
                            phoneNum = extend.get("phoneNum");
                        }
                    }
                    if (extend != null) {
                        String simIndex = null;
                        simIndex = extend.get("simIndex");
                        if (simIndex != null) {
                            data.put("simIndex", simIndex);
                        }
                    }
                     /*SDK-473 hewengao 20160603 start */
                    startWebActivity(context, data, type, phoneNum, extend);
                     /*SDK-473 hewengao 20160603 end */
                    return;
                }
            }
        }
        catch (JSONException e) {
            // TODO Auto-generated catch block
            // e.printStackTrace();
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w(Constant.TAG, "toService: ", e);
            /*SDK-550 hewengao 20160719 end*/
        }

        if ("repaymentService".equalsIgnoreCase(actionType)) {
            repaymentService(context, data, extend);
        }
        else if ("rechargeService".equalsIgnoreCase(actionType)) {
            rechargeService(context, data, extend);
        }
        else if ("trafficService".equalsIgnoreCase(actionType)) {
            trafficService(context, data, extend);
        }
        else {
            // otherService(context, data, extend);
            // 执行未来的未知类型
            LocalActionImpl.doActionOnImpl(context, actionType, data);
        }
    }

    /**
     * 还款服务
     * 
     * @param context
     * @param data
     * @throws JSONException
     */
    public void repaymentService(Context context, JSONObject data, Map<String, String> extend) {
        if (data.has("type")) {
            try {
                if ("ZFB_REPAYMENT".equalsIgnoreCase(data.getString("type"))) {

                    zfbRepayment(context, data);
                }
                else if ("ALIPAY_REPAYMENT".equalsIgnoreCase(data.getString("type"))) {

                    String appName = data.getString("appName");
                    if (checkHasAppName(context, appName)) {
                        String repayAmount = (String) JsonUtil.getValueFromJsonObject(data, "repayAmount");
                        String bankCode = (String) JsonUtil.getValueFromJsonObject(data, "bankCode");
                        String cardNumber = (String) JsonUtil.getValueFromJsonObject(data, "cardNumber");
                        String holderName = (String) JsonUtil.getValueFromJsonObject(data, "holderName");
                        ZFButil.zfbHuanKuan(context, cardNumber, repayAmount, holderName, bankCode, false);
                    }
                    else {

                        data.put("type", "WEB_URL");// 网页还款
                         /*SDK-473 hewengao 20160603 start */
                        startWebActivity(context, data, "WEB_URL", null, extend);
                         /*SDK-473 hewengao 20160603 end */
                    }
                }
                else if ("WEXIN_REPAYMENT".equalsIgnoreCase(data.getString("type"))) {

                    String rappName = data.getString("appName");
                    if (checkHasAppName(context, rappName)) {

                        AppUtil.startAPP(context, rappName);

                    }
                    else {

                        data.put("type", "WEB_URL");
                         /*SDK-473 hewengao 20160603 start */
                        startWebActivity(context, data, "WEB_URL", null, extend);
                         /*SDK-473 hewengao 20160603 end */
                    }

                }
                else if ("TENPAY_REPAYMENT".equalsIgnoreCase(data.getString("type"))) {
                    String rappName = data.getString("appName");

                    if (checkHasAppName(context, rappName)) {

                        // AppUtil.startAPP(context, rappName);
                        AppUtil.startAPP(context, rappName);
                    }
                    else {

                        data.put("type", "WEB_URL");
                        /*SDK-473 hewengao 20160603 start */
                        startWebActivity(context, data, "WEB_URL", null, extend);
                        /*SDK-473 hewengao 20160603 end */
                    }

                }
                else if ("BAIDU_REPAYMENT".equalsIgnoreCase(data.getString("type"))) {
                    String url = data.optString("url");
                    if (StringUtils.isNull(url)) {
                        url = data.optString("appName");
                    }
                    openUrl(context, url, data);

                }
                else {
                    otherRepayment(context, data, extend);
                }
            }
            catch (JSONException e) {
                // TODO Auto-generated catch block
                // e.printStackTrace();
                /*SDK-550 hewengao 20160719 start*/
                LogManager.w(Constant.TAG, "repaymentService: ", e);
                /*SDK-550 hewengao 20160719 end*/
            }
        }

    }

    /**
     * 充值服务
     * 
     * @param context
     * @param data
     * @throws JSONException
     */
    public void rechargeService(Context context, JSONObject data, Map<String, String> extend) {
        if (data.has("type")) {
            try {
                if ("ZFB_RECHARGE".equalsIgnoreCase(data.getString("type"))) {
                    // 从json data中获取simdex填入拓展参数中
                    if (extend == null) {
                        extend = new HashMap<String, String>();
                        if (data.has("simIndex")) {
                            extend.put("simIndex", data.getString("simIndex"));
                        }
                        if (data.has("exphone")) {
                            extend.put("exphone", data.getString("exphone"));
                        }
                    }
                    zfbRecharge(context, data, extend);
                }else if ("ALIPAY_RECHARGE".equalsIgnoreCase(data.getString("type"))) {
                    // 从json data中获取simdex填入拓展参数中
                    if (extend == null) {
                        extend = new HashMap<String, String>();
                        if (data.has("simIndex")) {
                            extend.put("simIndex", data.getString("simIndex"));
                        }
                        if (data.has("exphone")) {
                            extend.put("exphone", data.getString("exphone"));
                        }
                    }

                    String appName = JsonUtil.getValFromJsonObject(data, "appName").toString();
                    String phone = null;
                    if (extend != null) {
                        phone = extend.get("exphone");
                    }
                    if (StringUtils.isNull(phone)) {
                        phone = XyUtil.getPhoneNumber(context);
                    }
                    if (!StringUtils.isNull(appName) && checkHasAppName(context, appName)) {

                        ZFButil.zfbChongZhi(context, phone);
                    }
                    else {
                        data.put("type", "WEB_URL");
                         /*SDK-473 hewengao 20160603 start */
                        startWebActivity(context, data, "WEB_URL", null, extend);
                         /*SDK-473 hewengao 20160603 start */
                    }
                }
                else if ("WEXIN_RECHARGE".equalsIgnoreCase(data.getString("type"))) {

                    String rappName = data.getString("appName");
                    if (checkHasAppName(context, rappName)) {

                        AppUtil.startAPP(context, rappName);

                    }
                    else {

                        data.put("type", "WEB_URL");
                         /*SDK-473 hewengao 20160603 start */
                        startWebActivity(context, data, "WEB_URL", null, extend);
                         /*SDK-473 hewengao 20160603 end */
                    }

                }
                else if ("TENPAY_RECHARGE".equalsIgnoreCase(data.getString("type"))) {
                    String rappName = data.getString("appName");

                    if (checkHasAppName(context, rappName)) {
                        AppUtil.startAPP(context, rappName);

                    }
                    else {

                        data.put("type", "WEB_URL");
                        /*SDK-473 hewengao 20160603 start */
                        startWebActivity(context, data, "WEB_URL", null, extend);
                        /*SDK-473 hewengao 20160603 start */
                    }

                }
                else if ("BAIDU_RECHARGE".equalsIgnoreCase(data.getString("type"))) {
                    String url = data.optString("url");
                    if (StringUtils.isNull(url)) {
                        url = data.optString("appName");
                    }

                    openUrl(context, url, data);

                }
                else {
                    otherRecharge(context, data, extend);
                }
            }
            catch (JSONException e) {
                // TODO Auto-generated catch block
                // e.printStackTrace();
                /*SDK-550 hewengao 20160719 start*/
                LogManager.w(Constant.TAG, "rechargeService: ", e);
                /*SDK-550 hewengao 20160719 start*/
            }
        }

    }

    /**
     * 流量服务
     * 
     * @param context
     * @param data
     * @throws JSONException
     */
    public void trafficService(Context context, JSONObject data, Map<String, String> extend) {
        if (data.has("type")) {
            try {
                if ("WEB_TRAFFIC_ORDER".equalsIgnoreCase(data.getString("type"))) {
                    String phoneNum = "";
                    if (extend != null && !extend.isEmpty()) {
                        if (StringUtils.isNull(phoneNum)) {
                            phoneNum = extend.get("phone");
                        }
                        if (StringUtils.isNull(phoneNum)) {
                            phoneNum = extend.get("phoneNum");
                        }

                    }

                    if (extend != null) {
                        String simIndex = null;
                        simIndex = extend.get("simIndex");
                        if (simIndex != null) {
                            data.put("simIndex", simIndex);
                        }
                    }
                     /*SDK-473 hewengao 20160603 start */
                    startWebActivity(context, data, "WEB_TRAFFIC_ORDER", phoneNum, extend);
                     /*SDK-473 hewengao 20160603 end */
                }
                else if ("TAOBAO_TRAFFIC".equalsIgnoreCase(data.getString("type"))) {

                    String rappName = data.getString("appName");
                    if (checkHasAppName(context, rappName)) {

                        AppUtil.startAPP(context, rappName);

                    }
                    else {

                        data.put("type", "WEB_URL");
                         /*SDK-473 hewengao 20160603 start */
                        startWebActivity(context, data, "WEB_URL", null, extend);
                         /*SDK-473 hewengao 20160603 end */
                    }

                }
                else if ("WEIXIN_TRAFFIC".equalsIgnoreCase(data.getString("type"))) {
                    String rappName = data.getString("appName");

                    if (checkHasAppName(context, rappName)) {

                        AppUtil.startAPP(context, rappName);

                    }
                    else {

                        data.put("type", "WEB_URL");
                        /*SDK-473 hewengao 20160603 start */
                        startWebActivity(context, data, "WEB_URL", null, extend);
                        /*SDK-473 hewengao 20160603 end */
                    }

                }
                else if ("TENPAY_TRAFFIC".equalsIgnoreCase(data.getString("type"))) {
                    String rappName = data.getString("appName");

                    if (checkHasAppName(context, rappName)) {

                        AppUtil.startAPP(context, rappName);

                    }
                    else {

                        data.put("type", "WEB_URL");
                        /*SDK-473 hewengao 20160603 start */
                        startWebActivity(context, data, "WEB_URL", null, extend);
                        /*SDK-473 hewengao 20160603 end */
                    }

                }
                else {
                    otherOrderTraffic(context, data, extend);
                }
            }
            catch (JSONException e) {
                // TODO Auto-generated catch block
                // e.printStackTrace();
                /*SDK-550 hewengao 20160719 start*/
                LogManager.w(Constant.TAG, "trafficService: ", e);
                /*SDK-550 hewengao 20160719 end*/
            }
        }

    }

    /**
     * 充值
     * 
     * @param context
     * @param url
     */
    private void recharge(Context context, JSONObject data) {

        zfbRecharge(context, data, null);

    }

    /**
     * 根据传入参数充值
     * 
     * @param context
     * @param data
     * @param extend
     */
    public int recharge(Context context, JSONObject data, Map<String, String> extend) {
        zfbRecharge(context, data, extend);
        return 0;
    }

    /**
     * 还款
     * 
     * @param context
     * @param url
     */
    public void repayment(Context context, JSONObject data) {
        zfbRepayment(context, data);
    }

    /**
     * 支付宝还款
     * 
     * @param context
     * @param url
     */
    public void zfbRepayment(Context ac, JSONObject data, Map<String, String> extend) {
        try {
            String appName = data.getString("appName");
            if (checkHasAppName(ac, appName)) {
                String repayAmount = (String) JsonUtil.getValueFromJsonObject(data, "repayAmount");
                String bankCode = (String) JsonUtil.getValueFromJsonObject(data, "bankCode");
                String cardNumber = (String) JsonUtil.getValueFromJsonObject(data, "cardNumber");
                String holderName = (String) JsonUtil.getValueFromJsonObject(data, "holderName");
                ZFButil.zfbHuanKuan(ac, cardNumber, repayAmount, holderName, bankCode, false);
            }
            else {
                // String url = data.getString("appDownUrl");
                // downLoadUrl(ac, url);

                data.put("type", "WEB_REPAYMENT");// 网页还款
                 /*SDK-473 hewengao 20160603 start */
                startWebActivity(ac, data, "WEB_REPAYMENT", null, extend);
                 /*SDK-473 hewengao 20160603 end */
            }
        }
        catch (Throwable e) {
            // TODO: handle Throwable
            /*SDK-550 hewengao 20160719 start*/
            LogManager.e("xiaoyuan", "AbsSdkDoAction.zfbRepayment : ", e);
            /*SDK-550 hewengao 20160719 end*/
        }

    }

    /**
     * 支付宝还款
     * 
     * @param context
     * @param url
     */
    public void zfbRepayment(Context ac, JSONObject data) {
        zfbRepayment(ac, data, null);
    }

    /**
     * 支付宝充值 根据传入参数充值
     * 
     * @param context
     * @param data
     * @param extend
     */
    public void zfbRecharge(Context ac, JSONObject data, Map<String, String> extend) {
        try {
            String appName = JsonUtil.getValFromJsonObject(data, "appName").toString();
            String phone = null;
            if (extend != null) {
                phone = extend.get("exphone");
            }
            if (StringUtils.isNull(phone)) {
                phone = XyUtil.getPhoneNumber(ac);
            }
            if (!StringUtils.isNull(appName) && checkHasAppName(ac, appName)) {

                ZFButil.zfbChongZhi(ac, phone);
            }
            else {
                // String url = data.getString("appDownUrl");
                // downLoadUrl(ac, url);
                String simIndex = "-1";
                if (extend != null) {
                    simIndex = extend.get("simIndex");
                }
                if (simIndex == null) {
                    simIndex = "-1";
                }
                data.put("simIndex", simIndex);
                if (phone != null) {
                    data.put("chang_phone", phone);
                }
                data.put("type", "WEB_CHONG_ZHI");
                 /*SDK-473 hewengao 20160603 start */
                startWebActivity(ac, data, "WEB_CHONG_ZHI", null, extend);
                 /*SDK-473 hewengao 20160603 end */
            }

        }
        catch (Throwable e) {
            // TODO: handle Throwable
        }

    }

    /**
     * 打开应用依据包名
     * 
     * @param context
     * @param appName
     */
    public void openAppByAppName(Context context, String appName) {
        PackageManager packageManager = context.getPackageManager();
        Intent intent = new Intent();
        intent = packageManager.getLaunchIntentForPackage(appName);
        setNewTaskIfNeed(context, intent);
        context.startActivity(intent);
    }

    /**
     * 检测是否安装的了指定应用
     * 
     * @param context
     * @param appName
     * @return
     */
    public boolean checkHasAppName(Context context, String appName) {
        try {
            PackageManager packageManager = context.getPackageManager();
            /*SDK-753 yangzhi 20170406 start */
            packageManager.getPackageInfo(appName, 0);
            /*SDK-753 yangzhi 20170406 end */
            return true;
        }
        catch (Throwable e) {
            // e.printStackTrace();
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w(Constant.TAG, "checkHasAppName: ", e);
            /*SDK-550 hewengao 20160719 end*/
        }

        return false;
    }

    /**
     * 打开应用依据包名,如果没有包名则引导下载
     * 
     * @param context
     * @param appName
     *            应用包名
     * @param appDownUrl
     *            应用app下载地址
     */
    public void openAppByAppName(Context context, String appName, String appDownUrl) {
        if (checkHasAppName(context, appName)) {
            PackageManager packageManager = context.getPackageManager();
            Intent intent = new Intent();
            intent = packageManager.getLaunchIntentForPackage(appName);
            setNewTaskIfNeed(context, intent);
            context.startActivity(intent);
        }
        else {
            if (!StringUtils.isNull(appDownUrl)) {
                downLoadUrl(context, appDownUrl);

            }
            else {
                Toast.makeText(context, "please check is installed  " + appName, Toast.LENGTH_LONG).show();
            }
        }
    }

    /**
     * 打开应用根据url
     * 
     * @param context
     * @param appName
     */
    public void openAppByUrl(Context context, String url, String appDownUrl) {

    }

    /**
     * 打开应用根据url
     * 
     * @param context
     * @param appName
     */
    public void openAppByUrl(Context context, String url) {

    }

    /**
     * 手机拔打电话 双卡需要指定卡位
     * 
     * @param phoneNum
     * @param sms
     *            短信内容
     * @param simIndex
     *            卡位 此值需要在 调用parseMsgToPopupWindow方法的时候
     *            在其extend函数中.加入simIndex的key将当前sim卡位传入. 单卡是可以不传.
     */
    public void callPhone(Context context, String phoneNum, int simIndex) {
        callPhone(context, phoneNum, simIndex, null);
    }

    /**
     * 手机拔打电话 双卡需要指定卡位
     * 
     * @param phoneNum
     * @param sms
     *            短信内容
     * @param simIndex
     *            卡位 此值需要在 调用parseMsgToPopupWindow方法的时候
     *            在其extend函数中.加入simIndex的key将当前sim卡位传入. 单卡是可以不传.
     */
    public void callPhone(Context context, String phoneNum, int simIndex, Map<String, String> extend) {

        phoneNum = phoneNum.replace("-", "");
        Intent i = new Intent();
        i.setAction(Intent.ACTION_CALL);
        i.setData(Uri.parse("tel:" + phoneNum));
        try {
            setNewTaskIfNeed(context, i);
            context.startActivity(i);
        }
        catch (Throwable e) {
        }
    }
    
    /**
     *  发送邮件
     */
    public void sendEmailTo(Context context, String emailAddr, Map extend) {
        ActionHelper.sendEmailTo(context, emailAddr, extend);
    }
    
//  /**
//   *  复制
//   */
//  public void copyCode(Context context, String code) {
//      ActionHelper.copyCode(context, code);
//  }
//  
    /**
     * 添加联系人 
     */
    public void addContact(Context context, String name, String phone, String email, String url, Map extend) {
        ActionHelper.addContact(context, name, phone, email, url, extend);
    }
    
    /**
     * 添加闹铃
     * 
     */
    public void addAlarm(Context context, int hour, int minute, Map extend) {
        ActionHelper.addAlarm(context, hour, minute, extend);
    }
    
    /**
     * 查看日历
     * 
     */
    public void viewCalendar(Context context, long timestamp, Map extend) {
        ActionHelper.viewCalendar(context, timestamp, extend);
    }

    /**
     *添加书签到系统默认浏览器
     * @param context
     * @param url
     */
    public void addBookMark(Context context, String url, Map extend){
        
    }

    /**
     * 发短信, 双卡需要指定卡位发短信.
     * 
     * @param phoneNum
     *            接收者号码
     * @param sms
     *            短信内容
     * @param simIndex
     *            卡位 此值需要在 调用parseMsgToPopupWindow方法的时候
     *            在其extend函数中.加入simIndex的key将当前sim卡位传入. -1表示没有传入卡位
     * @param params
     *            扩展参数
     */
    public abstract void sendSms(Context context, String phoneNum, String sms, int simIndex, Map<String, String> params);

    /**
     * 打开短信原文进入会话
     * 
     * @param context
     * @param phoneNum
     *            短信号码
     * @param params
     *            扩展参数
     */
    public abstract void openSms(Context context, String phoneNum, Map<String, String> params);

    /**
     * 根据号码获取联系人名称
     * 
     * @param context
     * @param phoneNum
     * @return
     */
    public abstract String getContactName(Context context, String phoneNum);

    /**
     * 标记短信已读
     * 
     * @param context
     * @param msgId
     */
    public abstract void markAsReadForDatabase(Context context, String msgId);

    /**
     * 删除短信
     * 
     * @param context
     * @param msgId
     */
    public abstract void deleteMsgForDatabase(Context context, String msgId);

    /**
     * 执行发送地图检索URL
     */
    public static final int DO_SEND_MAP_QUERY_URL = 0x1006;

    /**
     * 获取位置经纬度
     * 
     * @param context
     * @param handler
     */
    public void getLocation(Context context, Handler handler) {
        LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
                && !locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
            // 无法使用GPS与网络进行定位，显示没有找到相关结果提示
            handler.obtainMessage(NearbyPoint.QUERY_REQUEST_ERROR).sendToTarget();
            return;
        }

        Criteria criteria = new Criteria();
        // 设置粗略精确度
        criteria.setAccuracy(Criteria.ACCURACY_COARSE);
        // 设置是否需要返回海拔信息
        criteria.setAltitudeRequired(false);
        // 设置是否需要返回方位信息
        criteria.setBearingRequired(false);
        // 设置是否允许付费服务
        criteria.setCostAllowed(true);
        // 设置电量消耗等级
        criteria.setPowerRequirement(Criteria.POWER_HIGH);
        // 设置是否需要返回速度信息
        criteria.setSpeedRequired(false);

        // 使用GPS定位
        String provider = locationManager.getBestProvider(criteria, false);
        Location location = locationManager.getLastKnownLocation(provider);
        // 判断Location对象是否为空，为空，则使用网络定位
        if (location == null) {
            location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            if (location == null) {
                // 定位失败，显示没有找到相关结果提示
                handler.obtainMessage(NearbyPoint.QUERY_REQUEST_ERROR).sendToTarget();
                return;
            }
        }

        Message msg = handler.obtainMessage(DO_SEND_MAP_QUERY_URL);
        Bundle bundle = new Bundle();
        bundle.putDouble("latitude", location.getLatitude());
        bundle.putDouble("longitude", location.getLongitude());
        msg.setData(bundle);
        msg.sendToTarget();
    }

    /**
     * 获取第三方弹窗视图
     * 
     * @param context
     * @param phoneNum
     *            发送者号码
     * @param msgData
     *            消息数据 key: msgId 消息id key: simIndex 卡位 key: simName 卡名 key:
     *            msgTime 消息时间 key: smsContent 消息内容 如果msgData为null
     *            表示重新获取当前号码的视图无新数据,否则:表示新收到的数据 SdkCallBack callback 回调 -1 表示关闭
     * @return
     */
    public View getThirdPopupView(Context context, String phoneNum, Map<String, Object> msgData, SdkCallBack callback) {
        return null;
    }

    /**
     * 打开单个短信原文
     * 
     * @param context
     * @param msgId
     * @param extend扩展参数
     */
    public void openSmsDetail(Context context, String msgId, Map extend) {

    }

    public void doRemind(Context context, String msgid, String title, String eventLocation, String description,
            String startTime, String endTime, String remind, Map<String, String> extend) {
        try {
            Intent calIntent = new Intent();
            if (!(context instanceof Activity)) {
                calIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            }
            calIntent.setType("vnd.android.cursor.item/event");
            calIntent.setAction(Intent.ACTION_EDIT);

            if (!StringUtils.isNull(title)) {
                // 设置日程标题
                calIntent.putExtra(Events.TITLE, title);
            }

            if (!StringUtils.isNull(eventLocation)) {
                // 设置事件举行的地点
                calIntent.putExtra(Events.EVENT_LOCATION, eventLocation);
            }

            if (!StringUtils.isNull(description)) {
                // 设置事件描述
                calIntent.putExtra(Events.DESCRIPTION, description);
            }

            long start = StringUtils.getLongByString(startTime);
            if (start != -1) {
                calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, start);
            }
            long end = StringUtils.getLongByString(endTime);
            if (end != -1) {
                calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, end);
            }
            // 设置活动性质为默认
            calIntent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_DEFAULT);
            // // 设置将我的状态显示为暂定
            // calIntent.putExtra(Events.AVAILABILITY,
            // Events.AVAILABILITY_TENTATIVE);
            
            /* HUAWEI-1184 zhengxiaobo 20160606 begin */
            if(extend != null && extend.containsKey("founder_packagename")){
                calIntent.putExtra("founder_packagename", extend.get("founder_packagename"));
            }
            /* HUAWEI-1184 zhengxiaobo 20160606 end */
            
            context.startActivity(calIntent);
        }
        catch (Throwable e) {
            // TODO: handle Throwable
        }
    }

    public void doRemind(Activity context, Map<String, Object> extend) {

    }

    /**
     * 日程提醒，打开日历控件的添加事件视图
     * 
     * @param context
     * @param extend
     */
    public void doRemind(Context context, String msgid, Map<String, Object> extend) {
        if (context == null || extend == null || extend.size() == 0) {
            LogManager.w("doRemind", "activity为null或extend为空", null);
            return;
        }

        String title = null;// 日程标题
        String eventLocation = null;// 事件举行的地点
        String description = null;// 事件描述
        int year = -1;// 事件举行时间年
        int month = -1;// 事件举行时间月
        int day = -1;// 事件举行时间日
        int hour = -1;// 事件举行时间小时数
        int minute = -1;// 事件举行时间分钟数
        int minutesEarly = 120;// 提前几分钟进行事件提醒,默认提前120分钟

        // 如果短信解析结果存在日程标题则进行日程标题设置
        if (extend.containsKey("title_name")) {
            title = extend.get("title_name").toString();
        }
        // 如果短信解析结果存在事件举行的地点则进行事件举行的地点设置
        if (extend.containsKey("company_meetingreminder_add")) {
            eventLocation = extend.get("company_meetingreminder_add").toString();
        }
        // 如果短信解析结果存在事件召集人则在事件描述添加召集人信息
        if (extend.containsKey("company_meetingreminder_Convener")) {
            description = "召集人:" + extend.get("company_meetingreminder_Convener") + "  ";
        }
        // 如果短信解析结果存在事件描述则进行事件描述设置
        if (extend.containsKey("company_meetingreminder_theme")) {
            description += "主题:" + extend.get("company_meetingreminder_theme").toString();
        }
        // 如果短信解析结果存在事件举行日期信息则在事件描述添加事件举行日期信息
        if (extend.containsKey("company_meetingreminder_date")) {
            description += "  时间:" + extend.get("company_meetingreminder_date");
        }
        // 如果短信解析结果存在事件举行时间信息则在事件描述添加事件举行时间信息
        if (extend.containsKey("company_meetingreminder_time")) {
            description += " " + extend.get("company_meetingreminder_time");
        }

        Map<String, Integer> dataInfoMap = getDateInfoMap(extend.get("company_meetingreminder_date").toString(), extend
                .get("company_meetingreminder_time").toString());

        // 如果短信解析结果存在事件举行时间年则进行事件举行时间年设置
        if (dataInfoMap.containsKey("company_meetingreminder_date_year")) {
            year = dataInfoMap.get("company_meetingreminder_date_year");
        }
        // 如果短信解析结果存在事件举行时间月则进行事件举行时间月设置
        if (dataInfoMap.containsKey("company_meetingreminder_date_month")) {
            month = dataInfoMap.get("company_meetingreminder_date_month");
        }
        // 如果短信解析结果存在事件举行时间日则进行事件举行时间日设置
        if (dataInfoMap.containsKey("company_meetingreminder_date_day")) {
            day = dataInfoMap.get("company_meetingreminder_date_day");
        }
        // 如果短信解析结果存在事件举行时间小时数则进行事件举行时间小时数设置
        if (dataInfoMap.containsKey("company_meetingreminder_time_hour")) {
            hour = dataInfoMap.get("company_meetingreminder_time_hour");
        }
        // 如果短信解析结果存在事件举行时间分钟数则进行事件举行时间分钟数设置
        if (dataInfoMap.containsKey("company_meetingreminder_time_minute")) {
            minute = dataInfoMap.get("company_meetingreminder_time_minute");
        }
        // 如果短信解析结果存在提前几分钟进行事件提醒则进行提前几分钟进行事件提醒设置
        if (dataInfoMap.containsKey("company_meetingreminder_minutes_early")) {
            minutesEarly = dataInfoMap.get("company_meetingreminder_minutes_early");
        }

        Intent calIntent = new Intent();
        calIntent.setType("vnd.android.cursor.item/event");
        calIntent.setAction(Intent.ACTION_EDIT);

        // 设置日程标题
        calIntent.putExtra(Events.TITLE, title);
        // 设置事件举行的地点
        calIntent.putExtra(Events.EVENT_LOCATION, eventLocation);
        // 设置事件描述
        calIntent.putExtra(Events.DESCRIPTION, description);

        // 事件时间参数完整时设置事件提醒的起止日期
        if (year != -1 && month != -1 && day != -1 && hour != -1 && minute != -1 && minutesEarly != -1) {
            Calendar mCalendar = Calendar.getInstance();
            // 事件时间的年、月、日、时、分(月份由0开始计算，需要减一)
            mCalendar.set(year, month - 1, day, hour, minute);
            // 事件开始时间(事件时间-提前分钟数)
            mCalendar.add(Calendar.MINUTE, -minutesEarly);
            // 设置事件开始时间
            calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, mCalendar.getTimeInMillis());

            // 事件时间的年、月、日、时、分(月份由0开始计算，需要减一)
            mCalendar.set(year, month - 1, day, hour, minute);
            // 事件结束时间，事件时间的前十分钟结束
            mCalendar.add(Calendar.MINUTE, -10);
            // 设置事件结束时间
            calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, mCalendar.getTimeInMillis());
        }

        // 设置活动性质为默认
        calIntent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_DEFAULT);
        // 设置将我的状态显示为暂定
        calIntent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_TENTATIVE);
        setNewTaskIfNeed(context, calIntent);
        context.startActivity(calIntent);
    }

    /**
     * 获取中兴会议短信中的年月日时分信息
     * 
     * @param dateStr
     * @param timeStr
     * @return
     */
    private Map<String, Integer> getDateInfoMap(String dateStr, String timeStr) {
        Map<String, Integer> dataInfoMap = new HashMap<String, Integer>();

        try {
            int year = Integer.parseInt(dateStr.split("年")[0]);// 事件举行时间年
            int month = Integer.parseInt(dateStr.split("月")[0].split("年")[1]);// 事件举行时间月
            int day = Integer.parseInt(dateStr.split("月")[1].split("日")[0]);// 事件举行时间日
            int hour = Integer.parseInt(timeStr.split(":")[0]);// 事件举行时间小时数
            int minute = Integer.parseInt(timeStr.split(":")[1]);// 事件举行时间分钟数

            dataInfoMap.put("company_meetingreminder_date_year", year);
            dataInfoMap.put("company_meetingreminder_date_month", month);
            dataInfoMap.put("company_meetingreminder_date_day", day);
            dataInfoMap.put("company_meetingreminder_time_hour", hour);
            dataInfoMap.put("company_meetingreminder_time_minute", minute);
        }
        catch (Throwable e) {
            // e.printStackTrace();
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w(Constant.TAG, "getDateInfoMap: ", e);
            /*SDK-550 hewengao 20160719 end*/
        }

        return dataInfoMap;
    }

    /**
     * 创建卡片
     * 
     * @param result
     * @param cardType
     * @param extend
     * @return
     */
    public long createCard(JSONObject result, int cardType, Map<String, String> extend) {

        return 0;
    }

    /**
     * 获取扩展参数值
     * 
     * @param type
     *            1:获取卡位,所属省份和运营商
     * @param params
     * @return
     */
    public JSONObject getExtendValue(int type, JSONObject params) {
        JSONObject res = null;
        switch (type) {
        case 1:
            int simIndex = -1;
            if (params != null) {
                String sim = (String) JsonUtil.getValFromJsonObject(params, "simIndex");
                simIndex = getSimIndex(sim);
            }
            res = getProviceAndSP(simIndex);
            try {
                if (res == null) {
                    IccidInfo icc = IccidInfoManager.queryDeftIccidInfo(Constant.getContext());
                    if (icc != null) {
                        res = new JSONObject();
                        res.put("provice", icc.areaCode);
                        // 省份编码
                        res.put("sp", icc.operator);// 运营商
                    }
                }
                else {
                    String p = (String) JsonUtil.getValueFromJsonObject(res, "provice");
                    String pcode = IccidInfoManager.getProviceCode(p);
                    if (pcode != null) {
                        res.put("provice", pcode);
                    }
                }
            }
            catch (Throwable e) {
                // e.printStackTrace();
                /*SDK-550 hewengao 20160719 start*/
                LogManager.w(Constant.TAG, "getExtendValue: ", e);
                /*SDK-550 hewengao 20160719 end*/
            }
            break;
        }
        return res;
    }

    /**
     * 获取指定卡位,所属运营商和省份
     * 
     * @param simIndex
     *            -1:获取当前手机默认卡位,运营商和省份 0:卡1 1:卡2
     * @return key:provice value:省份 key:sp value:电信|移动|联通
     */
    public JSONObject getProviceAndSP(int simIndex) {
        String iccid = getIccidBySimIndex(simIndex);
        JSONObject res = null;
        try {
            if (iccid == null) {
                return null;
            }
            else {
                IccidInfo icc = IccidInfoManager.queryIccidInfo(iccid, Constant.getContext());
                if (icc != null) {
                    res = new JSONObject();
                    res.put("provice", icc.areaCode);
                    // 省份编码
                    res.put("sp", icc.operator);// 运营商
                }
            }
        }
        catch (Throwable e) {
            // e.printStackTrace();
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w(Constant.TAG, "getProviceAndSP: ", e);
            /*SDK-550 hewengao 20160719 end*/
        }
        return res;
    }

    /**
     * 获取指定卡位的iccid
     * 
     * @param simIndex
     *            -1:获取默认卡 0:卡1 1:卡2
     * @return iccid
     */
    public String getIccidBySimIndex(int simIndex) {
        return null;
    }

    /**
     * 获取指定卡位的手机号码
     * 
     * @param simIndex
     *            -1:获取默认卡 0:卡1 1:卡2
     * @return iccid
     */
    public String getPhoneNumberBySimIndex(int simIndex) {
        return null;
    }
    /*SDK-525 hewengao 20160707 start*/
    /***
     * return jsonobject {"mid":subscriberId,"iccid":simSerialNumber}
     */
    public JSONObject getTelephonyInfoBySimIndex(int simIndex) {
        return null;
    }
    /*SDK-525 hewengao 20160707 end*/
    public Drawable getDrawableByNumber(Context context, String number, Map<String, Object> extend) {
        return null;
    }

    public Drawable getHeadDrawableByNumber(Context context, String number, Map<String, Object> extend) {
        return null;
    }

    public int[] getHeadDrawableColorByNumber(Context context, String number, Map<String, Object> extend) {
        return null;
    }

    public void finishActivity(Context ac) {
        finishActivity(ac, null);
    }

    public void finishActivity(Context ac, Map<String, String> extend) {
        if (ac != null && ac instanceof Activity) {

            ((Activity) ac).finish();
        }
    }

    /**
     * get Receive Sms for before Scene recognition
     * 
     * @param phone
     *            sms sender's phone Optional param
     * @param minReceiveTime
     *            query Sms Receive minTime
     * @param maxReceiveTime
     *            query Sms Receive maxTime
     * @param limit
     *            query max count
     * @return List<JSONObject> JSONObject{
     *         "msgId":"消息ID","phone":"发送者号码","msg":"消息内容",
     *         "centerNum":"短信中心号码","smsReceiveTime":"短信接收时间long" }
     */
    public List<JSONObject> getReceiveMsgByReceiveTime(String phone, long startReceiveTime, long endReceiveTime,
            int limit) {
        return null;
    }

    /**
     * 根据号码获取联系人信息
     * 
     * @param context
     * @param phoneNum
     * @return { "contact_type":1, "contact_name":"陌生人" }  其中contact_type包括0:联系人、1:陌生人、2:骚扰
     */
    public JSONObject getContactObj(Context context, String phoneNum) {
        return null;
    }

    /**
     * 流量订购
     * 
     * @param context
     * @param extend
     *            扩展参数 mobile,rechargeAmount
     */
    public int orderTraiffc(Context context, JSONObject data, Map<String, String> extend) {
        try {
            serviceChoose(context, data, "WEB_TRAFFIC_CHOOSE", extend);
        }
        catch (JSONException e) {
            // TODO Auto-generated catch block
            // e.printStackTrace();
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w(Constant.TAG, "orderTraiffc: ", e);
            /*SDK-550 hewengao 20160719 end*/
        }
        return 0;

    }

    /**
     * 水电煤
     * 
     * @param context
     * @param data
     *            动作数据
     * @param extend
     *            扩展参数
     */
    public int payWaterGas(Context context, JSONObject data, Map<String, String> extend) {
        return 0;
    }

    /**
     * 其他充值调用
     * 
     * @param context
     * @param data
     * @param extend
     */
    public int otherRecharge(Context context, JSONObject data, Map<String, String> extend) {
        return 0;
    }

    /**
     * 其他还款调用
     * 
     * @param context
     * @param data
     * @param extend
     */
    public int otherRepayment(Context context, JSONObject data, Map<String, String> extend) {
        return 0;
    }

    /**
     * 其他流量订购调用
     * 
     * @param context
     * @param data
     * @param extend
     */
    public int otherOrderTraffic(Context context, JSONObject data, Map<String, String> extend) {
        return 0;
    }

    /**
     * 其他服务
     * 
     * @param context
     * @param data
     * @param extend
     */
    public int otherService(Context context, JSONObject data, Map<String, String> extend) {
        return 0;
    }

    public void onEventCallback(int eventType, Map<String, Object> extend) {

    }

    public boolean isContact(Context context, String phoneNumber) {
        return false;
    }

    public Set<String> loadPublicNumbers(Context context) {
        HashSet<String> hashSet = new HashSet<String>();
        Cursor cursor = null;
        try {
            cursor = context.getContentResolver().query(Uri.parse("content://mms-sms/canonical-addresses"),
                    new String[] { "address" }, null, null, null);
            if (cursor != null) {
                int addressColumn = cursor.getColumnIndex("address");
                while (cursor.moveToNext()) {

                    String address = cursor.getString(addressColumn);
                    if (!StringUtils.isNull(address)) {
                        String phoneNumber = address;
                        phoneNumber = StringUtils.replaceBlank(phoneNumber);
                        phoneNumber = StringUtils.getPhoneNumberNo86(phoneNumber);
                        if (!StringUtils.isNumber(phoneNumber))
                            continue;
                        if (!StringUtils.isPhoneNumber(phoneNumber)) {
                            hashSet.add(phoneNumber);
                        }

                    }

                }
            }
        }
        catch (Throwable e) {
            // e.printStackTrace();
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w(Constant.TAG, "loadPublicNumbers: ", e);
            /*SDK-550 hewengao 20160719 end*/
        }
        finally {
            try {
                cursor.close();
                cursor = null;
            }
            catch (Throwable e) {
                // e.printStackTrace();
                /*SDK-550 hewengao 20160719 start*/
                LogManager.w(Constant.TAG, "loadPublicNumbers: ", e);
                /*SDK-550 hewengao 20160719 end*/
                // TODO: handle Throwable
            }
        }
        return hashSet;

    }

    /**
     * SIM变更时调用
     */
    public void simChange() {

        NetUtil.executeRunnable(new Runnable() {

            @Override
            public void run() {
                try {
                    /*SDK-633 hewengao 20161009 start*/
                    SmartSmsThreadPoolManager.setThreadNameAndPriority(SmartSmsThreadPoolManager.TNAME_LOCAL_BG, Process.THREAD_PRIORITY_BACKGROUND);
                    /*SDK-633 hewengao 20161009 end*/
                    IccidLocationUtil.changeIccidAreaCode(true);
                }
                catch (Throwable e) {
                    /*SDK-550 hewengao 20160719 start*/
                    LogManager.w(Constant.TAG, "simChange", e);
                    /*SDK-550 hewengao 20160719 end*/
                }
            }
        });
    }

    /**
     * 华为渠道下判断是否是连接热点
     * 
     * @param mContext
     * @return 0:不是 1:是
     */
    public int getWifiType(Context mContext) {
        return 0;
    }

    /**
     * 
     * @param type
     *            1:验证码
     * @param extendMap
     *            type=1 key:vcode 表示验证码
     */
    public void parseMsgCallBack(int type, Map<String, Object> extendMap) {

    }

    public void closePopupWindow() {

    }

    public boolean isDoubleSimPhone() {
        return true;
    }
    public void logError(String tag, String errorInfo, Throwable e) {
        /*SDK-674 hewengao 20161114 start*/
        try {
            if (tag == null) tag = Constant.TAG;
            if (errorInfo == null) return;
            Log.e(tag, errorInfo);
        }catch (Throwable ex){
            //e.printStackTrace();
        }
        /*SDK-674 hewengao 20161114 end*/
    }

    /* SDK-556 huangzhiqiang 20160725 start */
    public void logInfo(String tag, String content, Map<String, Object> extend){
        /*SDK-674 hewengao 20161114 start*/
        try {
            if (tag == null) tag = Constant.TAG;
            if (content == null) return;
            Log.i(tag, content);
        }catch (Throwable e){
            //e.printStackTrace();
        }
        /*SDK-674 hewengao 20161114 end*/
    }
    /* SDK-556 huangzhiqiang 20160725 end */

    /***
     * 动作统计
     * 
     * @param titleNo
     * @param type
     *            1： 发短信 2： 打电话 3： 打开网址 4： 打开地图 5： 充值 6： 还款 7： 其它服务类型 8： 复制验证码
     *            9： 打开应用 10： 日程提醒 11： 水电煤 12： 流量订购 13：物流查询 14：航班查询 15：分期付款
     *            16：列车时刻 17：附近网点 18： 生活服务
     * @param extend
     */
    /* SDK-376 mobaohua 20160331 start */
    public void statisticAction(String titleNo, String type, Map<String, Object> extend) {
    }

    /* SDK-376 mobaohua 20160331 end */

    public void parseVersionChange(Context context, int verion) {

    }

    /**
     * 执行拓展动作
     * 
     * @param actionType
     *            动作类型
     * @param data
     *            数据
     * @param extend
     *            拓展参数
     */
    public void doExAction(Context ctx, String actionType, JSONObject data, Map extend) {

    }

    /**
     * 回复短信
     * 
     * @param context
     *            上下文
     * @param msgId
     *            短信消息id
     * @param phoneNum
     *            号码
     * @param content
     *            短信内容
     * @param extend
     *            拓展参数
     */
    public void replySms(Context context, String msgId, String phoneNum, String content, Map<String, String> extend) {

    }

    /**
     * 
     * @param msgid
     * @param phone
     * @param msg
     * @param url
     * @param extend
     * @return
     */
    public int checkValidUrl(String msgid, String phone, String msg, String url, Map extend) {
        return -999;
    }

    /*   *//**
     * 第三方url验证是否实现
     * 
     * @return
     */
    /*
     * public boolean isCheckValidUrlImpl(){ return false; }
     */

    public void clearPopup() {

    }

    /**
     * 
     * @param context
     * @param phoneNum
     * @param msgId
     */
    public void deleteMsgForDatabase(Context context, String phoneNum, String msgId, Map<String, String> extend) {

    }

    public static String getCurProcessName(int pid, Context context) {
        try {
            ActivityManager mActivityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
            if (mActivityManager == null) {
                return "";
            }
            List<RunningAppProcessInfo> runAppList = mActivityManager.getRunningAppProcesses();
            if (runAppList == null) {
                return "";
            }
            for (ActivityManager.RunningAppProcessInfo appProcess : runAppList) {
                if (appProcess.pid == pid) {
                    return appProcess.processName;
                }
            }
        }
        catch (Throwable e) {
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w("xiaoyuan", "getCurProcessName error: ", e);
            /*SDK-550 hewengao 20160719 end*/
        }
        return "";
    }

    /**
     * 判断是否需要newTask
     * 
     * @param context
     * @param intent
     */
    public void setNewTaskIfNeed(Context context, Intent intent) {
        if (context == null || intent == null)
            return;
        try {
            if (!(context instanceof Activity)) {
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            }
        }
        catch (Throwable e) {
            /*SDK-550 hewengao 20160719 start*/
            LogManager.w(Constant.TAG, "newTaskIfNeed=", e);
            /*SDK-550 hewengao 20160719 end*/
        }

    }

    /**
     * 获取短信内容中的日期数据，格式：[{"startTime":"1457406000000","endTime":"1457409600000"},
     * {"startTime":"1457499600000"}]
     * 
     * @param smsContent
     * @param smsReceiveTime
     * @return
     */
    public JSONArray getTimeSubInfo(String smsContent, long smsReceiveTime) {
        return null;
    }

    public String getresources(String resName, Map<String, String> extend) {
        return null;
    }

    /* SDK-383 xusongzhou 20160414 start */
    public void startWizardService(Context context, JSONObject param, Map extend) {
        // TODO override this function
    }

    public Boolean needRecognisedValue() {
        return true;
    }
    /* SDK-383 xusongzhou 20160414 end */
    
    /* QIKBOX-106/108 lilong 2016.04.26 starts */
    public Drawable getAirDrawableByFlyNo(Context context,String flyNo){
        return null;
    }
    /* QIKBOX-106/108 lilong 2016.04.26 end */
    
    /*SDK-382 /songzhirong/2016.05.05---start---*/

    public void doConversationAction(Context ctx, String actionType, JSONObject data, Map extend) {
        String phone = "";
        if(extend!=null&&extend.containsKey("phone")){
            phone = (String)extend.get("phone");
        }
        /*QIK-592 wangxingjian 20160727 begin*/
        if(data != null){
            String jsonString = data.optString("extendVal");
            JSONObject actJsonData =  null;
            if(!TextUtils.isEmpty(jsonString)){
                try {
                    actJsonData = new JSONObject(jsonString);
                    String cType = actJsonData.optString("type");
                    String cPhone = actJsonData.optString("phone");
                    String cTitle = actJsonData.optString("titleNo");
                    if(!StringUtils.isNull(cType)){
                        data.put("type", cType);
                        data.put("phone", cPhone);
                        data.put("titleNo",cTitle);
                    }
                } catch (Throwable e) {
                }
            }
        }
       /*QIK-592 wangxingjian 20160727 end*/
        
         /*SDK-473 hewengao 20160603 start */
         startWebActivity(ctx, data, actionType, phone,extend);
         /*SDK-473 hewengao 20160603 start */
    }
    /*SDK-382 /songzhirong/2016.05.05---end---*/
    
    /*SDK-464 hewengao 20160530 start*/
    public  AssetManager getExtendAssetManager(){
        return null;
    }
    /*SDK-464 hewengao 20160530 end*/
    
    /*SDK-473 hewengao 20160603 start */
    private boolean startWebActivity(Context context, JSONObject jsobj, String actionType, String phoneNum, Map<String, String> extend) {
    	boolean bl = callWebActivity(context, jsobj, actionType, phoneNum,extend);
        if (!bl) {
        	/*SDK-709 likuangkuang 20161227 start*/
            Intent intent = preStartWebActivity(context, jsobj, actionType, extend);
            if (intent != null) {
	            startWebActivity(context, intent);	        
	            /*SDK-709 likuangkuang 20170106 start*/
	            bl = true;
	            /*SDK-709 likuangkuang 20170106 end*/
            }
            
            /*SDK-709 likuangkuang 20161227 end*/            
        }
        
        return bl;
    }
    
    public boolean callWebActivity(Context context, JSONObject jsobj, String actionType, String phoneNum, Map<String, String> extend) {
        return false;
    }

    /*SDK-709 likuangkuang 20161227 start*/
    public void startWebActivity(Context context, Intent intent) {
    	context.startActivity(intent);
    }
    /*SDK-709 likuangkuang 20161227 end*/
    
    /**
     * 启动web Activity
     * 
     * @param context
     * @param jsobj
     * @param actionType
     */
    public static boolean openStartWebActivity(Context context, JSONObject jsobj, String actionType, String phoneNum, Map<String, String> extend) {
    	Intent intent = preStartWebActivity(context, jsobj, actionType, extend);
        if (intent == null) {
        	return false;
        }        
        context.startActivity(intent);      
        return true;
    }
    
    /*SDK-709 likuangkuang 20161227 start*/    
	private static Intent preStartWebActivity(Context context, JSONObject jsobj, String actionType,
			Map<String, String> extend) {
		Intent intent = null;
		try {
			intent = new Intent();
			intent.putExtra("actionType", actionType);
			/* SDK-548 zhaojiangwei 20160720 start */
			if (jsobj == null) {
				jsobj = new JSONObject();
			}
			String otherPackageName = null;
			String actionName = null;
			if (extend != null) {
			    otherPackageName = extend.get("otherPackageName");
			    actionName = extend.get("actionName");
	
			    if (extend.containsKey("bubbleJson")) {
			    	jsobj.put("bubbleJson", extend.get("bubbleJson"));
				}
			    /* SDK-548 zhaojiangwei 20160804 start */
			    if (extend.containsKey("checkString")) {
			    	jsobj.put("checkString", extend.get("checkString"));
			    }
			    /* SDK-548 zhaojiangwei 20160804 end */
			}
			intent.putExtra("JSONDATA", jsobj.toString());
			/* SDK-548 zhaojiangwei 20160720 end */
			if (!StringUtils.isNull(KeyManager.channel)) {
			    intent.putExtra("channel", KeyManager.channel);
			}
			if (!StringUtils.isNull(NetUtil.APPVERSION)) {
			    intent.putExtra("appVersion", NetUtil.APPVERSION);
			}
			/*SDK-481 hewengao 20160613 start */
			String sdkWebActivityClass =  DuoquUtils.getSdkDoAction().getConfig(AbsSdkDoAction.CONFIG_WEB_ACTIVITY_CLASS, null);
			if (StringUtils.isNull(otherPackageName)) {
			    // 当前应用
			     intent.setClassName(context, sdkWebActivityClass);
			    //intent2.setClassName(context, "cn.com.xy.sms.sdk.ui.popu.web.SdkWebActivity");
			} else {
			    // 启动第三方应用界面
			    intent.setClassName(otherPackageName, sdkWebActivityClass);
			    //intent2.setClassName(otherPackageName, "cn.com.xy.sms.sdk.ui.popu.web.SdkWebActivity");
			    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			}
			/*SDK-481 hewengao 20160613 end */
			
			if (!StringUtils.isNull(actionName)) {
			    intent.setAction(actionName);
			}
			// 判断context不是Activity时才set FLAG_ACTIVITY_NEW_TASK
			if (!(context instanceof Activity)) {
			    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			}
		} catch (Throwable e) {
	            // e.printStackTrace();
	            /*SDK-550 hewengao 20160719 start*/
	            LogManager.w(Constant.TAG, "preStartWebActivity: ", e);
	            /*SDK-550 hewengao 20160719 end*/
	    }
		
		return intent;
	}
    /*SDK-709 likuangkuang 20161227 end*/
	
    /*SDK-481 hewengao 20160613 start */
    public String getConfig(int type,Map extend){
        String res =null;
        switch(type){
        case CONFIG_VIEW_MANAGER_CLASS:
            res = "cn.com.xy.sms.sdk.ui.popu.util.ViewManger";
            break;
        case CONFIG_WEB_ACTIVITY_CLASS:
            res = "cn.com.xy.sms.sdk.ui.popu.web.SdkWebActivity";
            break;
        case CONFIG_UI_CONFIG_CLASS:
            res = "cn.com.xy.sms.sdk.ui.config.UIConfig";
            break;
        /* SDK-561 huangzhiqiang 20160725 start */
        case CONFIG_BEFORE_HAND_PARSE_SIZE:
            res = "50"; 
            break;
        /* SDK-561 huangzhiqiang 20160725 end */
        /*SDK-621 20160922 zhaojiangwei start */
        case CONFIG_NEARBY_ACTIVITY_CLASS:
            res = "cn.com.xy.sms.sdk.ui.popu.web.NearbyPointList";
            break;
         /*SDK-621 20160922 zhaojiangwei end */
        /*ONEPLUSCII-98 songzhirong 20161226 start*/
        case CONFIG_NOTIFY_ALL_ALGORITHM:
            res = "true";
        	break;
        /*ONEPLUSCII-98 songzhirong 20161226 start*/
        default:
            break;
        }
        return res;
    }
    /*SDK-481 hewengao 20160613 end */
    
    /*SDK-490 hewengao 20160616 start */
    public String getExtendConfig(int type,Map extend){
        try{
            if(type == EXTEND_CONFIG_PARSE_MSG){
                JSONObject extendCfg = new JSONObject();
                extendCfg.put("ref_basevalue","true");//引用基础识别结果
                extendCfg.put("ALLOW_PERSONAL_MSG","true");//支持私人转发
                return extendCfg.toString();
            }
        }catch(Throwable e){
            //e.printStackTrace();
        	LogManager.e("doaction", "getExtendConfig err:", e);
        }
        return null;
    }
    /*SDK-490 hewengao 20160616 end */
    
    /*SDK-668 zhaojiangwei 20161108 start */
    public void showXyToast(Context context,String toast,Map extend){
    	if(context == null || StringUtils.isNull(toast)){
    		return;
    	}
    	Toast.makeText(context,toast,Toast.LENGTH_SHORT).show();
    }
    /*SDK-668 zhaojiangwei 20161108 end */
    
    /*SDK-720 songzhirong 20170117 start */
    public void beforeInitBubbleView(Activity context,HashSet<String> phoneSet){
    	
    }
    /*SDK-720 songzhirong 20170117 end */
	
	public boolean defaultFunctionSwitch(int funcType) {
    	return false;
    }
	
	 /**
     * 获取设备型号sim卡对应的运营商
     * @param simIndex -1:当前手机默认卡位; 0:卡1; 1:卡2
     * @param iccid: 当前短信所属的iccid
     * @return  OPERATOR_UNKNOWN:未知, OPERATOR_CMCC:中移, OPERATOR_CUCC:中国联通, OPERATOR_CTCC:中国电信
     */
    public int getModelOperator(int simIndex, String iccid) {
        return OPERATOR_UNKNOWN;
    }
    

    /**
     * 更新短信msgId对应的sceneid,
     * @param msgId 短信消息的msgId
     * @param sceneId 短信消息的sceneId
     */
    public void updateSmsSceneId(String msgId, String sceneId){};

    /* NUBIA-334/yangzhi/2017.06.13---start--- */
    /**
     * 是否允许访问网络
     * (第三方可以根据自己的逻辑重写，并返回true或者false)
     * @param context
     * @return true:允许(默认) | false:不允许
     */
    public boolean isNetworkEnable(Context context) {
        return true;
    }
    /* NUBIA-334/yangzhi/2017.06.13---end--- */
}
